require(["config"], function() {
	require(["jquery", "template", "cookie", "header"], function($, template) {
		function Detail() {
			this.loadDetail();
			this.loadUsername();
		}

		$.extend(Detail.prototype = {
			loadUsername() {
				$.cookie.json = true;
				this.username = $.cookie("login-user");
				if(this.username) {
					var html = template("already_login", {
						username: this.username
					});
					$(".login_title").html(html);
				}
			},
			loadDetail() {
				$.ajax("http://rap2api.taobao.org/app/mock/94517/api/detail")
					.done(function(data) {
						var data = {
							ls: data.res_body.list
						}
						console.log(data);
						//渲染
						var html = template("pro_info", data);
						$(".product_info").html(html);
					});
			}
			/*loadThumbnail() {
			}*/

		});
		new Detail();
	});
});